package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.TbUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * description:
 *
 * @Author youhongwei
 * @Create 2025/6/17 13:34
 * @Version 1.0
 */
@RestController
@RequestMapping("user/index")
public class UserController {

    @Autowired
    private TbUserService tbUserService;

    /**
     * 登录
     * @param tbUserVo
     * @return
     */
    @PostMapping("login")
    public R login(@RequestBody TbUserVo tbUserVo){
        return tbUserService.login(tbUserVo);
    }

    /**
     *发送验证码
     * @param phone
     * @return
     */
    @PostMapping("sendCode/{phone}")
    public R sendCode(@PathVariable("phone") @Validated String phone){
        return tbUserService.sendCode(phone);
    }

    /**
     * 注册
     * @param tbUserVo
     * @return
     */
    @PostMapping("registerUser")
    public R registerUser(@RequestBody @Validated TbUserVo tbUserVo){
        return tbUserService.registerUser(tbUserVo);
    }
}
